package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class FindOperation implements IOperation{
    @Override
    public void work(BookList booklist) {
        System.out.println("查找图书");
        System.out.println("请输入你要查找的图书的书名：");
        Scanner scanner = new Scanner(System.in);
        String bookName = scanner.nextLine();
        int currentSize= booklist.getUsedSize();
        boolean find = true;
        for (int i = 0; i <currentSize ; i++) {
            Book book = booklist.getBook(i);
            if (book.getName().equals(bookName)) {
                System.out.println("找到：");
                System.out.println(book);
                find = false;
            }
        }
        if(find) {
            System.out.println("很抱歉！没有找到该图书");
        }
    }
   }
